import React from 'react';
import { connect } from 'dva';
// import { routerRedux } from 'dva/router';
// import { NavBar, Icon } from 'antd-mobile';
import CutImg from '../components/CutImg';

function SelectImage({ dispatch, physicianAuth }) {
  const { uploadToken, imgSrc, file } = physicianAuth;
  function getCropData(url) {
    dispatch({
      type: 'physicianAuth/setImage2',
      payload: {
        imgSrc: url,
      },
    });
  }
  return (
    <div>
      {/* <NavBar
        mode="light"
        icon={<Icon type="left" />}
        leftContent="返回"
        onLeftClick={() => {
          dispatch(routerRedux.push('/physicianAuth'));
        }}
        rightContent={[
          <span>完成</span>,
        ]}
      >医师头像</NavBar> */}
      <CutImg uploadToken={uploadToken} file={file} keyPrefix="doctor/head" src={imgSrc} getCropData={dataUrl => getCropData(dataUrl)} />
    </div>
  );
}


function mapStateToProps({ physicianAuth }) {
  return { physicianAuth };
}

export default connect(mapStateToProps)(SelectImage);
